package com.isnmp.nms.framework.discover.rstype;

import java.util.Iterator;
import java.util.List;
import java.util.Vector;

import com.isnmp.common.snmp.OMMappingInfo;
import com.isnmp.common.snmp.SNMPFactory;
import com.isnmp.nms.framework.discover.DeviceInfo;
import com.isnmp.nms.framework.discover.ResourceInfo;
import com.isnmp.nms.framework.discover.ResourceSearchMothType;

public abstract class SNMPTableBasicMothType extends ResourceSearchMothType {
    public abstract Class getORMappingClass();

    public abstract ResourceInfo tableMibInfoToResouce(Object paramObject);

    public SNMPTableBasicMothType() {
        setResouceBaseType(ResourceSearchMothType.ResouceBaseTypeSNMPTable);
    }

    /**
     * 获取资源信息
     */
    public List<ResourceInfo> getResoureInfo(DeviceInfo paramDeviceInfo) {
        Vector localVector = new Vector();
        try {
            List localList = SNMPFactory.getSNMPAPI().getAllTableData(getORMappingClass(), paramDeviceInfo.getSnmpTarget());
            Iterator localIterator = localList.iterator();
            while (localIterator.hasNext()) {
                OMMappingInfo omMappingInfo = (OMMappingInfo) localIterator.next();
                ResourceInfo resourceInfo = tableMibInfoToResouce(omMappingInfo);
                if (resourceInfo != null) {
                    resourceInfo.setLocalDevice(paramDeviceInfo);
                    resourceInfo.setResourceTypeName(getResoureTypeName());
                    resourceInfo.setResourceObjectInfo(resourceInfo);
                    resourceInfo.setResourceRSIDValue(omMappingInfo.getTableIndexOID());
                    localVector.add(resourceInfo);
                }
            }
        } catch (Exception localException) {
            localException.printStackTrace();
        }
        return localVector;
    }
}